package com.icode.core.dto.user;

import com.icode.core.model.user.City;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-4-7
 * Time: 上午10:36
 * To change this template use File | Settings | File Templates.
 */
public class CityDTO {

    private String id;
    private String cityName;
    private String provinceId;

    public CityDTO() {
    }

    public CityDTO(String id, String cityName, String provinceId) {
        this.id = id;
        this.cityName = cityName;
        this.provinceId = provinceId;
    }

    public static CityDTO toDTO(City city) {
        return new CityDTO(String.valueOf(city.id()), city.name(), String.valueOf(city.province().id()));
    }

    public static List<CityDTO> toDTOs(List<City> cities) {
        List<CityDTO> cityDTOs = new ArrayList<>();
        for (City c : cities) {
            CityDTO cityDTO = toDTO(c);
            cityDTOs.add(cityDTO);
        }
        return cityDTOs;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public void setProvinceId(String provinceId) {
        this.provinceId = provinceId;
    }

    public String getId() {
        return id;
    }

    public String getCityName() {
        return cityName;
    }

    public String getProvinceId() {
        return provinceId;
    }
}
